<?php

namespace App\Models\Scm;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Inbound extends Model
{
    use HasFactory;
    public $timestamps = FALSE;
    protected $table = 'biz_inbound';
    protected $fillable = ['id', 'inbound_code', 'qc_id', 'inbound_date', 'inbound_user_id', 'del_flag', 'status', 'receive_id', 'from_user_id', 'deliver_id', 'is_replenish', 'is_recon', 'is_write_off', 'supplier_id', 'create_time', 'update_time', 'receive_status',
                            'kingdee_code', 'kingdee_id', 'storage_org_unit', 'cost_center_org_unit', 'kingdee_contract_id', 'audit_time', 'kingdee_base_status', 'kingdee_inbound_type', 'kingdee_biz_type', 'transaction_type', 'last_update_time', 'kingdee_supplier_code', 'sync_time'];

    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);
    }

    public function findRowByKingdeeCode($kingdee_code){
        return self::whereRaw('BINARY kingdee_code = ?', [$kingdee_code])->first();
    }

    public function insertOne($params){
        return self::create($params);
    }

    public function insertMany($params){
        return self::insert($params);
    }

    public function updateById($params, $id){
        return self::where("id", $id)->update($params);
    }

    public function updateByKingdeeCode($params, $kingdee_code){
        return self::where("kingdee_code", $kingdee_code)->update($params);
    }

    public function findRowById($id){
        return self::whereRaw('BINARY id = ?', [$id])->first();
    }
}
